﻿using System.Web.Http;
using DefaultConnection;
using MementoWeb.Models;

namespace MementoWeb.Controllers
{
    public class PersonController : ApiController
    {
        private readonly IDataRepository _dataRepository; 

        public PersonController(IDataRepository dataRepository)
        {
            _dataRepository = dataRepository;
        }

        public Person GetById( int id )
        {
            return _dataRepository.GetPersonById(id);
        }

        public void CreateNew( Person person )
        {
            _dataRepository.CreateNewPerson(person);
        }

        public void Update( Person person )
        {
            _dataRepository.SavePersonChanges(person);
        }

        public void Delete( int id )
        {
            _dataRepository.DeletePerson(id);
        }

        // POST api/values
        public void Post(string value)
        {
        }
    }
}
